<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"  %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.regex.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.lang.System" %>
<%@ page import="twitter4j.*" %>
<%@ page import="twitter4j.http.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>트위터 로그인</title>
</head>
<body>
<%
//App Key 지정. App을 등록한 후 발급받은 키를 입력
String CONSUMER_KEY = "lLDr77zex3PnPUV5bI9ow";
String CONSUMER_SECRET = "LZQ9bR9MR2eiknDeJsTpfCaCZvQSRnBXRK56D9prx0";
//트위터인스턴스생성
Twitter twitter= new TwitterFactory().getInstance();
//키등록
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
//인증요청토큰생성
RequestToken reqToken= null;
reqToken= twitter.getOAuthRequestToken();
String tokenSecret= reqToken.getTokenSecret();
String token = reqToken.getToken();
//세션에 토큰 저장
session.setAttribute("reqkey", tokenSecret);
session.setAttribute("req", token);
%>
<Script Language="JavaScript">
 location.href = "<%=reqToken.getAuthorizationURL()%>";
</Script>
</body>
</html>